import { ref } from 'vue'
import { defineStore } from 'pinia'
import type { MicroGlobalData } from './type.d.ts'

export const useMicroGlobalData = defineStore('microGlobalData', () => {
  const microGlobalData = ref<MicroGlobalData>({
    token: '',
    reduxData: {
      user: {
        userInfo: null
      },
      menu: {
        menu: [],
        navKey: null,
        asideMenu: []
      },
      auth: {
        permissions: []
      }
    },
    axiosInstance: null,
    storageUtils: null
  })
  const actions = ref({})
  function initMicroGlobal(micro: MicroGlobalData) {
    microGlobalData.value = micro
  }
  const setActions = (actions: any) => {
    actions.value = actions
  }
  return { microGlobalData, initMicroGlobal, setActions }
})
